{% extends 'users/user-base.html' %}

{% load static %}
{% block title %}域内服务节点{% endblock %}
{% block custom_css %}
    {#    <link href="css/domain.css" rel="stylesheet" title="" type="text/css"/>#}
    <style>
        td{
            vertical-align:middle !important;
        }
    </style>
{% endblock %}

{% block custom_js %}{% endblock %}

{% block contentworkstation %}
    <script type="text/javascript">
        $(document).ready(function () {
            $("#tab").on("click", ":button", function (event) {
                var btn_id = $(this).attr('id');
                var workstation_name = $(this).closest("tr").find("td").eq(1).text();
                var domain_ip = $(this).closest("tr").find("td").eq(2).text();
                if (btn_id == 'del') {
                    $.ajax({
                        type: "POST",
                        data: {
                            'workstation_name': workstation_name,
                            'domain_ip': domain_ip,
                        },
                        url: "/admins/delete_workstation/",
                        success: function (data) {
                            if (data["st"] === 1) {
                                alert("成功");
                                window.location.reload();
                            }
                        },
                        error: function () {
                            alert("失败");
                        }
                    })
                }
            })
        })

    </script>
        <div class="dashboard-wrapper">
            <div class="dashboard-ecommerce">
                <div class="container-fluid dashboard-content ">
                    <!-- ============================================================== -->
                    <!-- pageheader  -->
                    <!-- ============================================================== -->
                    <div class="row">
                        <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                            <div class="page-header">
                                <h2 class="pageheader-title">域内服务节点</h2>
                                <div class="page-breadcrumb">
                                    <nav aria-label="breadcrumb">
                                        <ol class="breadcrumb">
                                            <li class="breadcrumb-item">域管理</a></li>
                                            <li class="breadcrumb-item active" aria-current="page">域内服务节点</li>
                                        </ol>
                                    </nav>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- ============================================================== -->
                    <!-- end pageheader  -->
                    <!-- ============================================================== -->

                    <div class="row">
                        <!-- ============================================================== -->
                        <!-- basic table  -->
                        <!-- ============================================================== -->
                        <div class="col-xl-12 col-lg-12 col-md-12 col-sm-12 col-12">
                            <div class="card">
                                <div class="card-body">
                                    <div class="table-responsive">
                                        <table class="table table-striped table-bordered first" id="tab">
                                            <thead>
                                            <tr>
                                                <th >ID</th>
                                                <th >服务节点</th>
                                                <th >网关地址</th>
                                                <th >端口</th>
                                                <th >域内地址</th>
                                                <th >用户名</th>
                                                <th >密码</th>
                                                <th >部署时间</th>
                                                <th>操作</th>
                                            </tr>
                                            </thead>
                                            <form id="workstationform">
                                                {% for workstation in data %}
                                                    <tr>
                                                        <td>{{ forloop.counter }}</td>
                                                        <td>{{ workstation.host_name }}</td>
                                                        <td>{{ workstation.domain_ip }}</td>
                                                        <td>{{ workstation.ssh_port }}</td>
                                                        <td>{{ workstation.ip }}</td>
                                                        <td>{{ workstation.user }}</td>
                                                        <td>{{ workstation.pwd }}</td>
                                                        <td>{{ workstation.deploy_time }}</td>
                                                        <td>
                                                            <button type="button" class="btn btn-danger" id="del"
                                                                   name="del">
                                                                <span class="glyphicon glyphicon-trash"></span>
                                                                删除
                                                            </button>
                                                        </td>
                                                    </tr>
                                                {% endfor %}
                                            </form>
                                        </table>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>


{% endblock %}